package com.loubobooo.personal.blog.service.impl;

import com.loubobooo.personal.blog.entity.Options;
import com.loubobooo.personal.blog.entity.vo.OptionsVO;
import com.loubobooo.personal.blog.mapper.OptionsMapper;
import com.loubobooo.personal.blog.mapper.custom.OptionsMapperCustom;
import com.loubobooo.personal.blog.service.OptionsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service public class OptionsServiceImpl implements OptionsService {

    @Autowired private OptionsMapperCustom optionsMapperCustom;

    @Autowired private OptionsMapper optionsMapper;

    @Override public OptionsVO getOptions() {
        Options options = optionsMapperCustom.getOptions();
        OptionsVO optionsVO = new OptionsVO();
        if (options != null) {
            BeanUtils.copyProperties(options, optionsVO);
            return optionsVO;
        }
        return null;
    }

    @Override public void insertOptions(Options options) {
        optionsMapper.insertSelective(options);
    }

    @Override public void updateOptions(Options options) {
        optionsMapper.updateByPrimaryKeySelective(options);
    }
}
